﻿using System;

using Fuse8.DomainFramework.Domain;
using Fuse8.DomainFramework.Common;

namespace Fuse8.DomainFramework.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class StubUnitOfWorkFactory<T> : HttpContextUnitOfWorkFactory<T>
        where T : class, IEntityObject, new()
    {
        /// <summary>
        /// 
        /// </summary>
        public StubUnitOfWorkFactory()
        {
            CurrentHttpContext = DummyHttpContext.GetInstance();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="withTransaction"></param>
        /// <returns></returns>
        public override IUnitOfWork<T> Create(bool withTransaction)
        {
            return new StubUnitOfWork<T>();
        }

        /// <summary>
        /// 
        /// </summary>
        public override void CommitTransaction()
        { }

        /// <summary>
        /// 
        /// </summary>
        public override void RollbackTransaction()
        { }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TMain"></typeparam>
        /// <param name="unitOfWork"></param>
        /// <returns></returns>
        public override IUnitOfWork<T> CreateFrom<TMain>(IUnitOfWork<TMain> unitOfWork)
        {
            return new StubUnitOfWork<T>();
        }
    }
}
